Note search enables you to find notes by searching for text in the title, content, or attributes of the notes. You also have the option to save your searches, which will create a special search note which is visible on your navigation tree and contains the search results as sub-items.

Types of search

There are multiple types of searches, all using the same search mechanism and query language:

Accessing the search

Interaction

To search for notes, click on the magnifying glass icon on the toolbar or press the keyboard shortcut.

  1. Set the text to search for in the Search string field.
    1. Apart from searching for words literally, there is also the possibility to search for attributes or properties of notes.
    2. See the examples below for more information.
  2. To limit the search to a note and its sub-children, set a note in Ancestor.
    1. This value is also pre-filled if the search is triggered from a hoisted note or a workspace.
    2. To search the entire database, keep the value empty.
  3. To limit the search to only a few levels of hierarchy (e.g. look in sub-children but not in sub-sub-children of a note), set the depth field to one of the provided values.
  4. In addition to that, the search can be configured via the Add search options buttons, as described in the follow-up section.
  5. Press Search to trigger the search. The results are displayed below the search configuration pane.
  6. The Search & Execute actions button is only relevant if at least one action has been added (as described in the section below).
  7. The Save to note will create a new note with the search configuration. For more information, see Saved Search.

Features

Autocomplete

To help with the syntax, Trilium offers an autocomplete functionality which can be triggered by pressing Ctrl+Space.

Some suggestions also open on their own as you type: label and relation names after # and ~, fields after ., operators, values, and notes after @. Keywords such as and, or, not, orderBy and limit appear only on Ctrl+Space, since a plain word is usually a search term.

No suggestion is selected when the list opens, so Enter runs the search as typed. To insert a suggestion, select it with Down and press Enter.

The autocomplete offers:

Syntax highlighting

The search input features syntax highlighting, making recognized fields such as note. and operators like NOT stand out.

Error highlighting & linting

The search is also checked for errors in two phases, which will be displayed as a red squiggle:

An error the search only runs into while running, such as an operator that note content cannot be searched with, is shown in a Search error card instead: below the search string, or at the top of the Quick search results.

Multiline

Long or complicated searches can be formatted by using newlines, similar to SQL queries. Newlines are treated just like spaces.

To add a new line, press Shift+Enter.

Search options

Click on which search option to apply from the Add search option section.

The options available are:

  1. Search script
    1. This feature allows writing a Code note that will handle the search on its own.
  2. Fast search
    1. The search will not look into the content of the notes, but it will still look into note titles and attributes, relations (based on the search query).
    2. This method can speed up the search considerably for large databases.
  3. Include archived
    1. Archived Notes will also be included in the results, whereas otherwise they would be ignored.
  4. Order by
    1. Allows changing the criteria for ordering the results, for example to order by creation date or alphabetically instead of by relevancy (default).
    2. It's also possible to change the order (ascending or descending) of the results.
  5. Limit
    1. Limits the results to a given maximum.
    2. This can help if the number of results would otherwise be high, at the cost of not being able to view all the results.
  6. Debug
    1. This will print additional information in the server log (see Error logs), regarding how the search expression was parsed.
    2. This function is especially useful after understanding the search functionality in detail, in order to determine why a complex search query is not working as expected.
  7. Action
    1. Apart from just searching, it is also possible to apply actions such as to add a label or a relation to the notes that have been matched by the search.
    2. Unlike other search configurations, here it's possible to apply the same action multiple times (i.e. in order to be able to apply multiple labels to notes).
    3. The actions given are the same as the ones in Bulk Actions, which is an alternative for operating directly with notes within the Note Tree.
    4. After defining the actions, first press Search to check the matched notes and then press Search & Execute actions to trigger the actions.

Viewing search results

Results appear below the search pane as a list of snippet cards. Each card shows the note title and a short excerpt of the text that matched.

The search will also highlight the words from the title or content that matched:

In addition: 

Simple Note Search Examples

Advanced Use Cases

See also Under the hood for more syntax references.

Search with Note Properties

Notes have properties that can be used in searches, such as noteId, dateModified, dateCreated, isProtected, type, title, text, content, rawContent, ownedLabelCount, labelCount, ownedRelationCount, relationCount, ownedRelationCountIncludingLinks, relationCountIncludingLinks, ownedAttributeCount, attributeCount, targetRelationCount, targetRelationCountIncludingLinks, parentCount, childrenCount, isArchived, contentSize, noteSize, and revisionCount.

These properties can be accessed via the note. prefix, e.g., note.type = code AND note.mime = 'application/json'.

Order by and Limit

#author=Tolkien orderBy #publicationDate desc, note.title limit 10

This example will:

  1. Find notes with the author label "Tolkien".
  2. Order the results by publicationDate in descending order.
  3. Use note.title as a secondary ordering if publication dates are equal.
  4. Limit the results to the first 10 notes.

Negation

Some queries can only be expressed with negation:

#book AND not(note.ancestors.title = 'Tolkien')

This query finds all book notes not in the "Tolkien" subtree.

Under the Hood

See the dedicated page to understand how progressive search works in Trilium, as well as some advanced use cases.

Auto-Trigger Search from URL

You can open Trilium and automatically trigger a search by including the search url encoded string in the URL:

http://localhost:8080/#?searchString=abc

Search Configuration

Parameters

Parameter Value Description
MIN_FUZZY_TOKEN_LENGTH 3 Minimum characters the ~= and ~* operators accept
MAX_EDIT_DISTANCE 2 Ceiling on character changes, reached only by 7+ character terms; shorter terms allow fewer. See the Fuzzy tolerance section above
RESULT_SUFFICIENCY_THRESHOLD 5 Minimum exact results before fuzzy fallback
MAX_CONTENT_SIZE 10MB Maximum note content size for search processing

Limits